<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>
    /**
     * 1.typeof 2.instanceof 3.constructor 4.Object.prototype.toString.call()
    */

    console.log(typeof 2); //number
    console.log(typeof true); //boolean  
    console.log(typeof 'str'); //string
    console.log(typeof []); //object
    console.log(typeof function () { }); //function
    console.log(typeof {}); //object
    console.log(typeof undefined); //undefined
    console.log(typeof null); //object

    console.log(2 instanceof Number); //false
    console.log(true instanceof Boolean); //false
    console.log('str' instanceof String); //false
    console.log([] instanceof Array); //true
    console.log(function () { } instanceof Function); //true
    console.log({} instanceof Object); //true

    const num1 = new Number(123);
    console.log(num1 instanceof Number);//true
    console.log(num1 instanceof Object);//true

    const str1 = new String("abcdef");
    console.log(str1 instanceof String);//true
    console.log(num1 instanceof Object);//true

    console.log((2).constructor === Number); //true
    console.log((true).constructor === Boolean); //true
    console.log(('str').constructor === String); //true
    console.log(([]).constructor === Array); //true
    console.log((function () { }).constructor === Function); //true
    console.log(({}).constructor === Object); //

    var a = Object.prototype.toString
    console.log(a.call(2)); //[object Number]
    console.log(a.call(true)); //[object Boolean]
    console.log(a.call('str')); //[object String]
    console.log(a.call([])); //[object Array]
    console.log(a.call(function () { })); //[object Function]
    console.log(a.call({})); //[object Object]
    console.log(a.call(undefined)); //[object Undefined]
    console.log(a.call(null)); //[object Null]
  </script>
</body>

</html>